import matplotlib.pyplot as plt
import numpy as np

# 创建数据
categories = ['A', 'B', 'C', 'D', 'E']
values = [23, 45, 56, 78, 32]
errors = [2, 3, 4, 5, 3]

# 创建图表
fig, ax = plt.subplots(figsize=(10, 6))

# 绘制柱状图
bars = ax.bar(categories, values, yerr=errors, capsize=5, 
              color=['red', 'green', 'blue', 'orange', 'purple'], 
              alpha=0.7)

# 添加标题和标签
ax.set_title('Bar Chart Example with Error Bars', fontsize=16)
ax.set_xlabel('Categories', fontsize=12)
ax.set_ylabel('Values', fontsize=12)

# 在柱子上添加数值标签
for bar, value in zip(bars, values):
    ax.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 1, 
            str(value), ha='center', va='bottom', fontsize=10)

# 显示图表
plt.tight_layout()
plt.show()